﻿using System;

namespace Needle.Utils.Extensions
{
    /// <summary>
    /// Generic array extension methods
    /// </summary>
    public static class ArrayExtensions
    {
        /// <summary>
        /// returns a copy of the array starting at <c>index</c> with length <c>length</c>.
        /// </summary>
        public static T[] Slice<T>(this T[] array, int index, int length)
        {
            if (array == null)
                throw new NullReferenceException();
            T[] slice = new T[length];
            Array.Copy(array, index, slice, 0, length);
            return slice;
        }

    }
}
